<include file="Footprint:header"/>
<include file="Footprint:share_header"/>
</head>
<body>
<div class="pop-box1">
    <img class="load-bee" src="/assets/activity/footprint/images/load-bee.png"/>

</div>
<div class="wraper">
    <div class="top bg-color8" style="margin-bottom: 8px;">
        <div class="logobox fl-left">
            <span class="iconfont icon-zuo" onclick="javascript:history.back()"></span>
        </div>
        <div class="title fl-left">评论</div>
    </div>
    <div id="comment-list">
	    <volist name="data" id="vo">
	    	<div class="box clearfix">
		        <img class="comment-img fl-left" src="{BEESCRM:$vo.headimgurl}"/>
		        <div class="comment-box fl-left">
		            <p>{BEESCRM:$vo.nickname}</p>
		            <p class="comment">{BEESCRM:$vo.comment}</p>
		            <p class="time">{BEESCRM:$vo.create_time|date='Y-m-d',###}
		            <for start="0" end="$vo.star">
		            	 <span class="iconfont icon-xingxing star-y"></span>
		            </for>
		            </p>
		        </div>
		    </div>
	    </volist>
    </div>
	<if condition="count($data) eq 5">
	   	<div class="box clearfix" style="margin-bottom: 55px">
	   		<input type="hidden" id="page" value="2">
				<a class="comment" style="text-align: center;padding: 5px 0;display: block" id="more">查看更多</a>
	    </div>
	</if>
    <div class="btn-box">
        <a href="javascript:void(0)" class="big-btn btn fl-left bg-color9" id="isay">我来评论</a>
    </div>
    
    <div class="pop-box" id="only-cover"></div>
	<div class="pop clearfix" id="commend">
		<div class="prize picture white fl-left"><if condition="$firstPic">
			<img src="{BEESCRM:$firstPic}"/>
			<else/>
			<img src="/assets/activity/footprint/images/center-bg.jpg"/>
		</if>
		</div>
		<p class="prize-name fl-left">
			<span id="sumComment">评论（{BEESCRM:$sum}）</span>
		</p>
		<span class="iconfont icon-guanbi guanbi"></span>
		<p class="grade fl-left">我来评分
			<input id="star" type="hidden" name="star" value="5" />
			<span class="iconfont icon-xingxing star-y" id="comment_1" onclick="change(1)"></span>
			<span class="iconfont icon-xingxing star-y" id="comment_2" onclick="change(2)"></span>
			<span class="iconfont icon-xingxing star-y" id="comment_3" onclick="change(3)"></span>
			<span class="iconfont icon-xingxing star-y" id="comment_4" onclick="change(4)"></span>
			<span class="iconfont icon-xingxing star-y" id="comment_5" onclick="change(5)"></span>
		</p>
		<input type="hidden"  id="point_id" value="{BEESCRM:$point_id}"/>
		<textarea class="textarea" id="comment" placeholder="说说我的感受，提点小小的建议~"></textarea>
		<div>
			<a href="javascript:void(0)" class="big-btn btn fl-left bg-color8" id="publish">发表评论</a>
		</div>
	</div>
    
</div>
<script type="text/javascript">
function change(aid) {
    for (i = 1; i <= aid; i++) {
        $('#comment_' + i).removeClass('star-n').addClass('star-y');
    }
    for (i = 5; i > aid; i--) {
    	$('#comment_' + i).removeClass('star-y').addClass('star-n');
    }
    $('#star').val(aid);
}
$(document).on('click','#publish',function(){
	var star = $('#star').val();
	var point_id = $('#point_id').val();
	var comment = $('#comment').val();
	comment = comment.replace(/^\s+|\s+$/g,"");
	if(!comment){
		infotips('评论内容不能为空',$('.submit_tips'));
		return false;
	}
	
	$.ajax({
         type:'post',
         dataType:'json',
         data:{'point_id':point_id,'star':star,'comment':comment},
         url:"{BEESCRM::U('/Activity/Footprint/addComment',array('wechat_id'=>$wechat_id,'act_id'=>$act_id))}",
         success:function(data){
        	 if(data.status == 'S'){
        		console.log(data);
        		infotips('评论成功',$('.submit_tips'),'right');
				window.location.reload();
        		//$('#comment-list').append(data.html);
        		$('#comment').val('');
        		//$('#star').val('5');
				 $('#only-cover').fadeOut(500);
        		 $('#commend').removeClass('up');
        		 $('#sumComment').html('评论 （ '+data.sum+'）');
			}else{
				infotips('通讯错误',$('.submit_tips'));
			}
         },
         error:function(){
        	 infotips('通讯错误',$('.submit_tips')); 
         },
       });
	});


	$('#isay').click(function(){
		$('#only-cover').show();
		$('#commend').addClass('up');
	});
	$('.guanbi').click(function(){
		$('#commend').removeClass('up');
		$('#only-cover').fadeOut(500);
	});
	
	$(document).on('click','#more',function(){
    	var p = $('#page').val();
    	var point_id = $('#point_id').val();
    	$('.pop-box1').show();
    	$.ajax({
	         type:'post',
	         dataType:'json',
	         data:{'point_id':point_id},
	         url:"{BEESCRM::U('/Activity/Footprint/moreComment',array('wechat_id'=>$wechat_id,'act_id'=>$act_id))}"+"/p/"+p,
	         success:function(data){
	        	 if(data.status == 'S'){
        			$("#comment-list").append(data.message);
					if(data.p == -1){
						$('#more').remove();
					}else{
						$('#page').val(data.p);
					}
					
				}else{
					infotips('请稍后再试',$('.submit_tips'));
				}
	        	 $('.pop-box1').hide();
	         },
	         error:function(){
	        	 infotips('请稍后再试',$('.submit_tips'));
	        	 $('.pop-box1').hide();
	         },
	       });
    });
</script>
</body>

</html>
